package com.link2room.rodimus.service.impl;

import cn.brandwisdom.gss.param.GssCreateParamDto;
import cn.brandwisdom.gss.result.ResutlGssDto;
import com.link2room.common.util.HttpUtil;
import com.link2room.common.util.JacksonUtil;
import com.link2room.common.util.LogUtil;
import com.link2room.common.util.StringUtil;
import com.link2room.rodimus.service.IGSSService;
import org.springframework.stereotype.Component;


/**
 * Created by VegetaKo on 2017/2/28.
 */
@Component("gSSService")
public class GSSServiceImpl implements IGSSService {

    @Override
    public ResutlGssDto getBrandwisdomGss(GssCreateParamDto gssCreateParamDto) throws Exception {
        //TODO 临时写死
        String uri="http://gw.brandwisdom.cn/router/rest";
        String resutlGss = HttpUtil.httpGet(uri, gssCreateParamDto);
        ResutlGssDto resutlGssDto = JacksonUtil.readValue(resutlGss, ResutlGssDto.class);
        if(!resutlGssDto.getStatus().getCode().equals("10000") ){
            //throw  new SysException(SysExceptionEnum.BRANDWISDOM_ERROR.getCode(),gssCreateParamDto,SysExceptionEnum.BRANDWISDOM_ERROR.getBizType());
        }
        if(StringUtil.isBlank(resutlGssDto.getData().getAnsurl())){
            LogUtil.logger.error("慧评报错:"+resutlGssDto.toString());
        }
        return resutlGssDto;

    }
}
